﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Green.AgileMapper
{
    public class MapperKey
    {
        public Type From
        { get; private set; }

        public Type To
        { get; private set; }

        public string MapperName
        { get; private set; }

        public MapperKey(Type from, Type to, string mapperName)
        {
            this.From = from;
            this.To = to;
            this.MapperName = mapperName;
        }

        public override bool Equals(object obj)
        {
            var o = obj as MapperKey;

            if (Object.ReferenceEquals(o, null))
                return false;
            return From.AssemblyQualifiedName.Equals(o.From.AssemblyQualifiedName) && To.AssemblyQualifiedName.Equals(o.To.AssemblyQualifiedName) && MapperName.Equals(o.MapperName);
        }

        public override int GetHashCode()
        {
            return From.GetHashCode() ^ To.GetHashCode() ^ MapperName.GetHashCode();
        }

        public static bool operator ==(MapperKey obj1, MapperKey obj2)
        {
            if (Object.ReferenceEquals(obj1, null))
                return false;
            return obj1.Equals(obj2);
        }

        public static bool operator !=(MapperKey obj1, MapperKey obj2)
        {
           return !(obj1==obj2);
        }
    }
}
